<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.PaymentSchedule;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.PaymentSchedule">
		<cfargument name="Payment_Schedule_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.Payment_Schedule_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new PaymentSchedule();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new PaymentSchedule();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.PaymentSchedule">
		<cfargument name="obj" type="assets.calgrants.com.bo.PaymentSchedule" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Payment_Schedule_ID")) {
				local.obj.setPayment_Schedule_ID(arguments.Payment_Schedule_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted); 
			}
			if (IsDefined("arguments.Cohort")) {
				local.obj.setCohort(arguments.Cohort); 
			}
			if (IsDefined("arguments.Scholarship_Type")) {
				local.obj.setScholarship_Type(arguments.Scholarship_Type);
			}
			if (IsDefined("arguments.Term")) {
				local.obj.setTerm(arguments.Term);
			}
			if (IsDefined("arguments.Term_Type")) {
				local.obj.setTerm_Type(arguments.Term_Type);
			}
			if (IsDefined("arguments.Verification_Type")) {
				local.obj.setVerification_Type(arguments.Verification_Type);
			}
			if (IsDefined("arguments.Verification_Soft_Deadline")) {
				local.obj.setVerification_Soft_Deadline(arguments.Verification_Soft_Deadline);
			}
			if (IsDefined("arguments.Verification_Hard_Deadline")) {
				local.obj.setVerification_Hard_Deadline(arguments.Verification_Hard_Deadline);
			}
			if (IsDefined("arguments.Payment_Amount")) {
				local.obj.setPayment_Amount(arguments.Payment_Amount);
			}
			if (IsDefined("arguments.Sort_Order")) {
				local.obj.setSort_Order(arguments.Sort_Order);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}			
			return local.obj;
		</cfscript>
	</cffunction>
	
	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Payment_Schedule_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Cohort" required="false" default="" />
		<cfargument name="Scholarship_Type" required="false" default="" />
		<cfargument name="Term" required="false" default="" />
		<cfargument name="Term_Type" required="false" default="" />
		<cfargument name="Verification_Type" required="false" default="" />
		<cfargument name="Verification_Soft_Deadline" required="false" default="" />
		<cfargument name="Verification_Hard_Deadline" required="false" default="" />
		<cfargument name="Payment_Amount" required="false" default="" />
		<cfargument name="Sort_Order" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readPaymentSchedule">
			<cfprocparam value="#arguments.Payment_Schedule_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Payment_Schedule_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Cohort#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Cohort)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Scholarship_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Scholarship_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Term#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Term)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Term_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Term_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Verification_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Verification_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Verification_Soft_Deadline#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Verification_Soft_Deadline)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Verification_Hard_Deadline#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Verification_Hard_Deadline)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Amount#" cfsqltype="CF_SQL_MONEY" null="#IIf(Len(Trim(arguments.Payment_Amount)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Sort_Order#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Sort_Order)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="paymentSchedule" required="true" type="assets.calgrants.com.bo.PaymentSchedule" />

		<cfstoredproc datasource="#getDatasource()#" procedure="savePaymentSchedule">
			<cfprocparam value="#paymentSchedule.getPayment_Schedule_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#paymentSchedule.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#paymentSchedule.getCohort()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#paymentSchedule.getScholarship_Type()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#paymentSchedule.getTerm()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#paymentSchedule.getTerm_Type()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#paymentSchedule.getVerification_Type()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#paymentSchedule.getVerification_Soft_Deadline()#" cfsqltype="CF_SQL_DATE" null="false" />
			<cfprocparam value="#paymentSchedule.getVerification_Hard_Deadline()#" cfsqltype="CF_SQL_DATE" null="false" />
			<cfprocparam value="#paymentSchedule.getPayment_Amount()#" cfsqltype="CF_SQL_MONEY" null="false" />
			<cfprocparam value="#paymentSchedule.getSort_Order()#" cfsqltype="CF_SQL_INTEGER" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Payment_Schedule_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyPaymentSchedule">
			<cfprocparam value="#arguments.Payment_Schedule_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

